<?php
	if (!session_start()) session_start();
	require_once("../librarys/funcs/Connection.php");
	require_once("../librarys/funcs/Utils.php");

	$p = $_GET['p'];
	$a = $_GET['a'];

	$conn = new Connection();
	$util = new Utils();
	if ($p == 'restaurant') {
		if ($a == 'get_item') {
			if (isset($_GET['id'])) {
				$id     = $_GET['id'];
				$record = $conn->get_all_data($table = 'restaurant_item', $id, 1);
				$re     = array('title'     => $record['title'], 'content' => $record['content'],
				                'url_image' => $record['url_image'],
				);
				echo json_encode($re);
			}
		}
		if ($a == 'list_item') {
			if (isset($_GET['id'])) {
				$id_menu     = $_GET['id'];
				$list_record = $conn->get_all_data_fix($table = 'restaurant_item', -1, 1, $option1 = ' AND restaurant_menu_id =' . $id_menu);
				$re_list     = array();
				foreach ($list_record as $key => $value) {
					$re1       = array('id'        => $value['id'],
					                   'title'     => $value['title'], 'content' => $value['content'],
					                   'url_image' => $value['url_image'],
					);
					$re_list[] = $re1;
				}

				echo json_encode($re_list);
			}
		}
	}
	if ($p == 'brand') {
		if ($a == 'get_item') {
			if (isset($_GET['id'])) {
				$id     = $_GET['id'];
				$record = $conn->get_all_data($table = 'brand', $id, 1);
				$re     = array('title'     => $record['name'], 'content' => $record['content'],
				                'url_image' => $record['url_image'],
				);
				echo json_encode($re);
			}
		}
	}

?>